From: kaf24@firebug.cl.cam.ac.uk Date: Tue, 27 Jun 2006 08:51:18 +0000 (+0100) Subject: [HVM][VMX] Added flag_dr_dirty to hvm vcpu struct. If this flag is set, X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~15913^2~32 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/%22bookmarks:///%22http:/www.example.com/cgi/%22https:/%22bookmarks:/?a=commitdiff_plain;h=bb8fad6de570747eee00b553111171c04aa05442;p=xen.git [HVM][VMX] Added flag_dr_dirty to hvm vcpu struct. If this flag is set, save the debug registers, clear the flag, and remove guest access to debug registers. Signed-off-by: George Dunlap Signed-off-by: Nitin Kamble --- diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c index 659dcdce10..07792d2918 100644 --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -359,6 +359,26 @@ static inline int long_mode_do_msr_write(struct cpu_user_regs *regs) #define loaddebug(_v,_reg) \ __asm__ __volatile__ ("mov %0,%%db" #_reg : : "r" ((_v)->debugreg[_reg])) +#define savedebug(_v,_reg) \ + __asm__ __volatile__ ("mov %%db" #_reg ",%0" : : "r" ((_v)->debugreg[_reg])) + +static inline void vmx_save_dr(struct vcpu *v) +{ + if ( v->arch.hvm_vcpu.flag_dr_dirty ) + { + savedebug(&v->arch.guest_context, 0); + savedebug(&v->arch.guest_context, 1); + savedebug(&v->arch.guest_context, 2); + savedebug(&v->arch.guest_context, 3); + savedebug(&v->arch.guest_context, 6); + + v->arch.hvm_vcpu.flag_dr_dirty = 0; + + v->arch.hvm_vcpu.u.vmx.exec_control |= CPU_BASED_MOV_DR_EXITING; + __vmwrite(CPU_BASED_VM_EXEC_CONTROL, + v->arch.hvm_vcpu.u.vmx.exec_control); + } +} static inline void __restore_debug_registers(struct vcpu *v) { @@ -409,6 +429,7 @@ static void vmx_ctxt_switch_from(struct vcpu *v) vmx_freeze_time(v); vmx_save_segments(v); vmx_load_msrs(); + vmx_save_dr(v); } static void vmx_ctxt_switch_to(struct vcpu *v) diff --git a/xen/include/asm-x86/hvm/vcpu.h b/xen/include/asm-x86/hvm/vcpu.h index 3503c57ffe..80dd267fc9 100644 --- a/xen/include/asm-x86/hvm/vcpu.h +++ b/xen/include/asm-x86/hvm/vcpu.h @@ -38,6 +38,9 @@ struct hvm_vcpu { /* For AP startup */ unsigned long init_sipi_sipi_state; + /* Flags */ + int flag_dr_dirty; + union { struct arch_vmx_struct vmx; struct arch_svm_struct svm;